package com.itcoon.demo.web.controller.exception;/**
 * @author Athric Yu
 * 2024/11/28
 **/

import com.itcoon.cloud.framework.ex.errorcode.CommonServiceErrorCode;
import com.itcoon.cloud.framework.webmvc.response.ApiResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 *
 * @author Athric Yu
 * 2024/11/28
 **/
@Tag(name = "异常测试")
@RequestMapping("exceptions")
@RestController
public class ExceptionController {

    @Operation(summary = "异常测试，flag=true为业务异常，flag=false为系统异常")
    @GetMapping
    public ApiResponse<Void> exception(@RequestParam boolean flag){
        if(flag){
            throw CommonServiceErrorCode.DEFAULT_SERVICE_EXCEPTION.bindException();
        }
        throw new RuntimeException();
    }
}
